package com.youlin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.youlin.dto.BaseDataResDto;
import com.youlin.dto.Status;
import com.youlin.entities.BygBgTemplate;
import com.youlin.mapper.BygBgTemplateMapper;
import com.youlin.service.BygBgTemplateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class BygBgTemplateServiceImpl extends ServiceImpl<BygBgTemplateMapper, BygBgTemplate> implements BygBgTemplateService {

    @Override
    public BaseDataResDto<List<BygBgTemplate>> findAllBgTls(Integer bgId, List<Integer> types) {
        LambdaQueryWrapper<BygBgTemplate> wrapper = Wrappers.lambdaQuery(BygBgTemplate.class);
        if (bgId != null) wrapper.eq(BygBgTemplate::getBgId, bgId);
        if (types != null && types.size() > 0) wrapper.in(BygBgTemplate::getType, types);
        List<BygBgTemplate> bgTemplates = list(wrapper.orderByAsc(BygBgTemplate::getType));
        return new BaseDataResDto<List<BygBgTemplate>>(Status.SUCCESS).setData(bgTemplates);
    }

}
